﻿@using AdminWeb.Views
@using NougakudoCompanion.Commons

<style type="text/css">
    .zip-name 
    {
        width: 500px;
    }
</style>

<div class="wraper">
    <div class="pagetilte">NougakuDo Companion Configuration</div>
    @{
        //
        Runtime runtime = ViewBag.Runtime;

        using (Html.BeginForm("InstallApplications", "Admin"))
        {
            string[] errors = new string[]{};
            if (ViewBag.Errors != null) { errors = ViewBag.Errors; }
            if (errors.Length != 0 )
            {
        <div id="Errors">
21          <div class="grey-border-alt">
            <div class="table-head">Error information</div>
            <div class="tab-padding">
              <div class="listing-tab">
                @foreach (var m in errors)
                {
                    WriteLiteral(m);<br />  
                }
              </div>
            </div>
          </div>
        </div>
        <p></p>
            }
        <div id="Runtime">
          <div class="grey-border-alt">
            <div class="table-head">NougakuDo Runtime - Required</div>
            <div class="tab-padding">
              <div class="listingHead">
                @Html.CheckBox("Runtime", true, null)
                @runtime.Environment.Name
              </div>
              <div class="listing-tab">
                <p>@Html.Hidden("RuntimeName", runtime.Environment.Name)</p>
                <p>Version:@Html.TextBox("RuntimeVersion", runtime.Environment.Version)</p>
              </div>
            </div>
          </div>
        </div>
        <p></p>
        <div id="InstalledApplication">
          <div class="grey-border-alt">
            <div class="table-head">Installed Applications - update info</div>
          @if (runtime.Applications.Count == 0)
          {
              <div class="listingHead">
          No Applications to be installed.
              </div>
          }
          else
          {
              foreach (var name in runtime.Applications.Keys)
              {
                  var app = runtime.Applications[name];
              <div class="listingHead">
                @Html.CheckBox(name, true, null)
                @name
              </div>
              <div class="listing-tab">
                @Html.Hidden("App" + name, app.Name)
                <p>Version:@Html.TextBox("App" + name + "Version", app.Version)</p>
                <p>Environment:@Html.DropDownList("App" + name + "Environment", ViewHelper.GetEnvironment(app.Environment))</p>
                <p># of processers:@Html.TextBox("App" + name + "NumOfProcessors", app.NumOfProcess.ToString())</p>
                <!-- Add for NougakuDo 1.1.0 above. -->
                <p>Virtual Host:@Html.CheckBox("App" + name + "VirtualHost", app.VirtualHost)<br />A virtual host can establish only 1 and support NougakuDo 1.1.0 above.</p>
              </div>
              }
          }
          </div>
        </div>
        <p></p>
        <div id="NewApplication">
          <div class="grey-border-alt">
            <div class="table-head">Add Applications - new app info</div>
              <div class="listingHead">
                @Html.CheckBox("NewApp", false, null)
                New App
              </div>
              <div class="listing-tab">
                <p>Name:@Html.TextBox("NewAppName")</p>
                <p>Version:@Html.TextBox("NewAppVersion")</p>
                <p>Environment:@Html.DropDownList("NewAppEnvironment", ViewHelper.GetEnvironment("development"))</p>
                <p># of processers:@Html.TextBox("NewAppNumOfProcessors")</p>
                <!-- Add for NougakuDo 1.1.0 above. -->
                <p>Virtual Host:@Html.CheckBox("NewAppVirtualHost", false)<br />A virtual host can establish only 1 and support NougakuDo 1.1.0 above.</p>
              </div>
          </div>
    </div>
    <p></p>
    <div class="floatRight">
      <br/>
      <input type="submit" title="Update Configuration" value="Update" class="btnOrange" />
    </div>
        }
    }
